#!/bin/bash
#
# sshd		Start up the OpenSSH server daemon
#
# chkconfig: 2345 55 25
# description: redis control script
#
# processname: redis

. /etc/init.d/functions

pron="redis"
conf="/usr/local/redis/redis.conf"
redis="/usr/local/redis/src/redis-server"
prog=$(basename $redis)
lockfile="/var/lock/subsys/redis"

start() {
    echo -n $"Starting $pron: "
    daemon $redis $conf
    retval=$?
    echo 
    [ $retval -eq 0 ] && touch $lockfile
    return $retval
}

stop() {
    echo -n $"Stoping $pron: "
    killproc $prog -QUIT
    retval=$?
    echo 
    [ $retval -eq 0 ] && rm -f $lockfile
    return $reval
}

restart() {
    stop
    sleep 1
    start
}

rh_status() {
    status $prog
}

rh_status_q() {
    rh_status &> /dev/null
}

case "$1" in 
    start)
        rh_status_q && exit 0
        $1
        ;;
    stop)
        rh_status_q || exit 0
        $1
        ;;
    restart)
        $1
        ;;
    status)
        rh_status
        ;;
    *)
        echo $"Uasge: $0 {start|stop|restart|status}"
        exit 2
esac
